<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>表单验证</title>
		<style>
			div{margin: 0 auto;width: 960px;text-align:center;}
		</style>
	</head>
	<body>
		<div >
			<h1>这是一个表单验证</h1>
			<form action="13368346625" method="post" onsubmit='return check();'>
				账号：
				<input type="text" name="username" id="username" value="" placeholder='用户名为手机号或邮箱'/><br/><br/>
				密码：
				<input type="password" name="password" id="password" value="" placeholder='请输入6-10位的密码'/><br/><br/>
				<input type="submit" name="btn1" id="btn1" value="提交" />
			</form>
		</div>
		<script>
			function check(){
				var username=document.getElementById('username').value;
				if((/0?(13|14|15|18)[0-9]{9}/.test(username)==false)&&(/\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/.test(username)==false))
					{
						alert('用户名不正确！');
						return false;
					}
				var passwd=document.getElementById('password').value;
				if(passwd.length<6||passwd.length>10)
					{
						alert('密码只能为6-10位！');
						return false;
					}
				return true;	
			}
		</script>
	</body>
</html>
